package com.创建型模型.D单例模式;

import java.lang.reflect.Constructor;

/**通过反射破坏单例
 * @author zhangjiawen
 * @Date: 2022/6/1 11:12
 */
enum LazyManEnum {
        INSTANCE;

        public void sayOk(){
            System.out.println("ok");
        }




    public static void main(String[] args) throws Exception {

        LazyManEnum instance = LazyManEnum.INSTANCE;
        System.out.println(instance);

        //Constructor<LazyManEnum> declaredConstructor = LazyManEnum.class.getDeclaredConstructor(null);
        Constructor<LazyManEnum> declaredConstructor = LazyManEnum.class.getDeclaredConstructor(String.class,int.class);
        declaredConstructor.setAccessible(true);
        LazyManEnum lazyManEnum = declaredConstructor.newInstance();
        System.out.println(lazyManEnum);


    }

}
